<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>38 configurable属性的用法</title>
	</head>
	<body>
		<script type="text/javascript">
			
			// configurable 可配置性,决定是否我们可以修改属性描述对象
			// 1.一旦设置configurable为false,属性描述对象 value,writable,enumrable,configurable都不能被修改
			/* var obj = Object.defineProperty({},'a',{
				value:1,
				writable:false,
				enumrable:false,
				configurable:false
			})
			// Cannot redefine property: a
			Object.defineProperty(obj,'a',{
				configurable: true
			})
			console.log(Object.getOwnPropertyDescriptor(obj,'a')); */
			// 2.注意:writable只有在false改为true的时候会静态失败,true改为false会允许的
		/* 	var obj2 = Object.defineProperty({},'p',{
				writable:true,
				configurable:false
			});
			Object.defineProperty(obj2,'p',{
				writable:false,
				configurable:false
			})
			obj2.p = 10;
			console.log(obj2);
			console.log(Object.getOwnPropertyDescriptor(obj2,'p')); */
			
			// 3.value属性 只要writable和 configurable有一个为true,就允许被修改
		/* 	var obj2 = Object.defineProperty({},'p',{
				value: 1,
				writable:false,
				configurable:true
			});
			Object.defineProperty(obj2,'p',{
				value:10
			})
			console.log(obj2);
			console.log(Object.getOwnPropertyDescriptor(obj2,'p')); */
			// configurable一旦被配置了true,可以被删除,否则就不能被删除
			var obj = Object.defineProperties({},{
				a:{
					value: 1,
					configurable: true
				},
				b:{
					value: 2,
					configurable: false
				}
			});
			delete obj.a;
			delete obj.b;
			console.log(obj);
		</script>
	</body>
</html>
